package edu.nf.takeoutdemo.commons.result;

import lombok.Data;
import org.apache.http.HttpStatus;

import java.io.Serializable;

/**
 *
 * @author zjl
 * @date 2025/10/23
 */
@Data
public class Result<T>implements Serializable {
    private Integer code;
    private String message;
    private T data;

    public static <T> Result<T> success() {
        Result<T> result = new Result<T>();
        result.setCode(HttpStatus.SC_OK);
        return result;
    }

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<T>();
        result.setCode(HttpStatus.SC_OK);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> error(int code, String message) {
        Result<T> vo = new Result<>();
        vo.setCode(code);
        vo.setMessage(message);
        return vo;
    }
}
